<?php include_once './header.php'; ?>

<?php 
include('config.php'); 
if (isset($_POST['submitted'])) { 
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
$sql = "INSERT INTO `fecha_actividad` ( `id_servicio_ad` ,  `fecha` ,  `lugar_encuentro`  ) VALUES(  '{$_POST['id_servicio_ad']}' ,  '{$_POST['fecha']}' ,  '{$_POST['lugar_encuentro']}'  ) "; 
mysql_query($sql) or die(mysql_error()); 
echo "Added row.<br />"; 
echo "<a href='listFechaServices.php'>Back To Listing</a>"; 
} 
?>
<script>
function gritar(id){
	var numDesc = document.getElementsByClassName("descripciones");
	for(var i=0; i< numDesc.length; i++){
		numDesc[i].style.display="none";
	}
	document.getElementById(id).style.display="block";
}
</script>
<div class="">
<div class="" style="position:relative; float:left; margin-right:50px;">
<form action='' method='POST'> 
<?php 
$result = mysql_query("SELECT * FROM serviciosadicionales where gratuito = '0' or gratuito = '1' ") or trigger_error(mysql_error()); 
$descripciones = mysql_query("SELECT * FROM serviciosadicionales where gratuito = '0' or gratuito = '1' ") or trigger_error(mysql_error()); 
echo "<p><b>Servicio</b><br /><select id='servicio' name='id_servicio_ad' onchange='gritar(this.value)'>";
		echo "<option value='xx'> -- </option>";	
		while($row = mysql_fetch_array($result)){ 
			echo "<option value='" . nl2br( $row['idServicio']) . "'>" .  $row['nombreServicio'] . "</option>";				
		}	
echo "</select></p>"; 
?>

<!--<p><b>Id Servicio Ad:</b><br /><input type='text' name='2id_servicio_ad2'/> -->
<p><b>Fecha:</b><br /><input type='text' id="f_date1" name='fecha' style="width: 120px;"/> <button id="f_btn1" class="calendarioButton"></button>
<script type="text/javascript">//<![CDATA[
			  Calendar.setup({
				inputField : "f_date1",
				trigger    : "f_btn1",
				onSelect   : function() { this.hide(); },
				dateFormat : "%Y-%m-%d"
			  });			 
			//]]></script>


<p><b>Lugar Encuentro:</b><br /><input type='text' name='lugar_encuentro'/> 
<p><input type='submit' value='Add Row' /><input type='hidden' value='1' name='submitted' /> 
</form> 
</div>
<div class="" style="position:relative; float:left;">
<p><b>Descripcion Servicio</b></p>
<?php
		while($row = mysql_fetch_array($descripciones)){ 
			echo "<div class='descripciones' id='" . nl2br( $row['idServicio']) . "'    style='display:none' >" .  $row['descServicio'] . "</div>";			
		}	
?>
</div>
</div>
<?php include_once './footer.php'; ?>